import axios from 'axios';
import { PageParam } from '@/api/global';
import { Channel } from '@/api/system/msg/channel';

const BASE_URL = '/orange-system/v1.0/messages';

export function pageMessage(params: MessagePageParam) {
  return axios.post(BASE_URL.concat('/page'), params);
}

export function listMessage(params: SearchMessageParam) {
  return axios.post(BASE_URL.concat('/list'), params);
}

export function deleteMessageById(id: string) {
  return axios.delete(BASE_URL.concat(`/${id}`));
}

export function addMessage(params: Message) {
  return axios.post(BASE_URL, params);
}

export function getMessageById(id: string) {
  return axios.get(BASE_URL.concat(`/${id}`));
}

export function getMessageDetailById(id: string) {
  return axios.get(BASE_URL.concat(`/${id}/detail`));
}

export function updateMessageById(id: string, params: Message) {
  return axios.put(BASE_URL.concat(`/${id}`), params);
}

export interface Message {
  tenantId?: string;
  id?: string;
  title?: string;
  content?: string;
  channel?: string;
}

export interface SearchMessageParam {
  title?: string;
  content?: string;
}

export type MessagePageParam = SearchMessageParam & PageParam;

export type MessageDetailQueryParam = {
  showMenu?: boolean;
  showButton?: boolean;
};
